/**
 * 
 */
package com.hp.bon.sgw.domain;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * SGW Core,dcc channel,soap channel,scsp channel
 * 
 * @author sunhaiy
 * 
 */
@Entity
@Table(name = "T_SGW_CHANNEL")
public class SGWChannel {

	private int id;
	private String channelHost;
	private String channelType;// dcc;scsp;soap
	private String uri;
	private int isStart;// 是否启动：0:表示不启动;1：表示启动;
	private int status;// channel当前状态：0:表示未启动;1:表示启动;
	private String channelDesc;
	private Date modifiedTime;
	private Date statusTime;
	private int maxRecvQueueSize;
  double recvQueuePercent = 0.0D;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "CHANNEL_HOST", nullable = false, length = 50)
	public String getChannelHost() {
		return channelHost;
	}

	public void setChannelHost(String channelHost) {
		this.channelHost = channelHost;
	}

	@Column(name = "IS_START")
	public int getIsStart() {
		return isStart;
	}

	public void setIsStart(int isStart) {
		this.isStart = isStart;
	}

	@Column(name = "STATUS")
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	@Column(name = "URI", nullable = true, length = 215)
	public String getUri() {
		return uri;
	}

	@Column(name = "CHANNEL_DESC", nullable = true, length = 215)
	public String getChannelDesc() {
		return channelDesc;
	}

	public void setChannelDesc(String channelDesc) {
		this.channelDesc = channelDesc;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}

	@Column(name = "CHANNEL_TYPE", nullable = false, length = 64)
	public String getChannelType() {
		return channelType;
	}

	public void setChannelType(String channelType) {
		this.channelType = channelType;
	}

	@Column(name = "MODIFIED_TIME", columnDefinition = "TIMESTAMP(6)")
	public Date getModifiedTime() {
		return modifiedTime;
	}

	public void setModifiedTime(Date modifiedTime) {
		this.modifiedTime = modifiedTime;
	}

	@Column(name = "STATUS_TIME", columnDefinition = "TIMESTAMP(6)")
	public Date getStatusTime() {
		return statusTime;
	}

	public void setStatusTime(Date statusTime) {
		this.statusTime = statusTime;
	}

	@Column(name = "MAX_RECV_QUEUE_SIZE")
	public int getMaxRecvQueueSize() {
		return maxRecvQueueSize;
	}

	public void setMaxRecvQueueSize(int maxRecvQueueSize) {
		this.maxRecvQueueSize = maxRecvQueueSize;
	}

	@Transient
	public String getRealm() {
		return this.channelHost.substring(channelHost.indexOf('@') + 1);
	}

	@Transient
	public double getRecvQueuePercent() {
		return recvQueuePercent;
	}

	public void setRecvQueuePercent(double recvQueuePercent) {
		this.recvQueuePercent = recvQueuePercent;
	}

	public String toString() {
		return "Channel{host=" + this.channelHost + ", uri=" + this.uri + "}";
	}
}
